package com.example.Arithmetic.Lettcode;

import java.util.ArrayDeque;

/**
 * 日期：2023/10/14
 * 时间：17:28
 * 描述：单队列模拟栈
 */
public class E04Lettcode225 {
    ArrayDeque<Integer> deque;

    public E04Lettcode225() {
        deque = new ArrayDeque<>();
    }


    public void push(int x) {
        deque.push(x);
        if (deque.size()>1) {
            for (int i = 0; i < deque.size(); i++) {
                deque.push(deque.pop());
            }
        }
    }

    public int pop() {
       return  deque.poll();
    }

    public int top() {
        return deque.peek();
    }

    public boolean empty() {
        return deque.isEmpty();
    }

}
